﻿@model DistributeTransaction.Models.OrderSummary
@{
    ViewBag.Title = "Orders Details";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>
    Orders Details
</h2>
<table>
    <thead>
        <tr>
            <th>
                Product ID
            </th>
            <th>@Html.ActionLink("Product Name", "Detail", new { orderId = ViewBag.OrderId, sortOrder = "ProductName|" + ViewBag.SortParm + "|" + ViewBag.SortDir })
            </th>
            <th align="right">@Html.ActionLink("Price", "Detail", new { orderId = ViewBag.OrderId, sortOrder = "Price|" + ViewBag.SortParm + "|" + ViewBag.SortDir })
            </th>
            <th align="right">@Html.ActionLink("Quantity", "Detail", new { orderId = ViewBag.OrderId, sortOrder = "Quantity|" + ViewBag.SortParm + "|" + ViewBag.SortDir })
            </th>
            <th align="right">@Html.ActionLink("Coupon", "Detail", new { orderId = ViewBag.OrderId, sortOrder = "Coupon|" + ViewBag.SortParm + "|" + ViewBag.SortDir })
            </th>
            <th align="right">@Html.ActionLink("Total", "Detail", new { orderId = ViewBag.OrderId, sortOrder = "Total|" + ViewBag.SortParm + "|" + ViewBag.SortDir })
            </th>
        </tr>
    </thead>
    <tfoot>
        <tr>
            <td>
                Summary:
            </td>
            <td />
            <td />
            <td />
            <td />
            <td>
                @ViewBag.TotalAmount
            </td>
        </tr>
    </tfoot>
    <tbody>
        @foreach (var item in Model.details)
        {
            <tr>
                <td>
                    @Html.DisplayFor(modelItem => item.ProductId)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.ProductName)
                </td>
                <td align="right">
                    @Html.DisplayFor(modelItem => item.UnitPrice)
                </td>
                <td align="right">
                    @Html.DisplayFor(modelItem => item.Quantity)
                </td>
                <td align="right">
                    @Html.DisplayFor(modelItem => item.Coupon)
                </td>
                <td align="right">
                    @Html.DisplayFor(modelItem => item.SubTotal)
                </td>
            </tr>
        }
    </tbody>
</table>
<div>
    <h3>
        Payment information</h3>
    <div>
        <table>
            <thead>
                <tr>
                    <th>
                        Transaction Id
                    </th>
                    <th>
                        @Html.ActionLink("Holder Name", "Detail", new { orderId = ViewBag.OrderId, sortOrder = "HoldName|" + ViewBag.SortParm + "|" + ViewBag.SortDir })
                    </th>
                    <th>
                        @Html.ActionLink("Card Number", "Detail", new { orderId = ViewBag.OrderId, sortOrder = "CardNumber|" + ViewBag.SortParm + "|" + ViewBag.SortDir })
                    </th>
                    <th align="right">
                        @Html.ActionLink("Amount", "Detail", new { orderId = ViewBag.OrderId, sortOrder = "Amount|" + ViewBag.SortParm + "|" + ViewBag.SortDir })
                    </th>
                    <th align="center">
                        @Html.ActionLink("Card Type", "Detail", new { orderId = ViewBag.OrderId, sortOrder = "CardType|" + ViewBag.SortParm + "|" + ViewBag.SortDir })
                    </th>
                    <th>
                        @Html.ActionLink("Status", "Detail", new { orderId = ViewBag.OrderId, sortOrder = "Status|" + ViewBag.SortParm + "|" + ViewBag.SortDir })
                    </th>
                </tr>
            </thead>
            <tbody>
                @foreach (var item in Model.Payments)
                {
                    <tr>
                        <td>
                            @Html.DisplayFor(modelItem => item.PaymentId)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.HoldName)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.CardNumber)
                        </td>
                        <td align="right">
                            @Html.DisplayFor(modelItem => item.Amount)
                        </td>
                        <td align="center">
                            @Html.DisplayFor(modelItem => item.CardType)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.Status)
                        </td>
                    </tr>
                }
            </tbody>
        </table>
    </div>
    <h3>
        Shipping Address</h3>
    <div>
        <table cellpadding="0" cellspacing="0" border="0" style="border: 0px;">
            <colgroup>
                <col width="25%"/>
                <col width="5%"/>
                <col width="55%"/>
                <col width="15%"/>
            </colgroup>
            <tbody>
                <tr>
                    <td>
                        <span class="editor-label">
                            @Html.LabelFor(model => Model.ShippedDate)
                        </span>
                    </td>
                    <td />
                    <td>
                        <span class="editor-field">
                            @Html.DisplayFor(model => Model.ShippedDate)
                        </span>
                    </td>
                    <td />
                </tr>
                <tr>
                    <td>
                        <span class="editor-label">
                            @Html.LabelFor(model => Model.ShipName)
                        </span>
                    </td>
                    <td />
                    <td>
                        <span class="editor-field">
                            @Html.DisplayFor(model => Model.ShipName)
                        </span>
                    </td>
                    <td />
                </tr>
                <tr>
                    <td>
                        <span class="editor-label">
                            @Html.LabelFor(model => Model.ShipAddress)
                        </span>
                    </td>
                    <td />
                    <td>
                        <span class="editor-field">
                            @Html.DisplayFor(model => Model.ShipAddress)
                        </span>
                    </td>
                    <td />
                </tr>
                <tr>
                    <td>
                        <span class="editor-label">
                            @Html.LabelFor(model => Model.ShipCity)
                        </span>
                    </td>
                    <td />
                    <td>
                        <span class="editor-field">
                            @Html.DisplayFor(model => Model.ShipCity)
                        </span>
                    </td>
                    <td />
                </tr>
                <tr>
                    <td>
                        <span class="editor-label">
                            @Html.LabelFor(model => Model.ShipPostalCode)
                        </span>
                    </td>
                    <td />
                    <td>
                        <span class="editor-field">
                            @Html.DisplayFor(model => Model.ShipPostalCode)
                        </span>
                    </td>
                    <td />
                </tr>
                <tr>
                    <td>
                        <span class="editor-label">
                            @Html.LabelFor(model => Model.ShipCountry)
                        </span>
                    </td>
                    <td />
                    <td>
                        <span class="editor-field">
                            @Html.DisplayFor(model => Model.ShipCountry)
                        </span>
                    </td>
                    <td />
                </tr>
            </tbody>
        </table>
    </div>
    <div>
    &nbsp;
    </div>
</div>
@using (Html.BeginForm("CancelOrder", "Order"))
{
    if (@ViewBag.CanCancel as string == "New")
    {
    <input type="submit" id="CancelOrder" value="Cancel Order" />
    }
    <input type="button" id="btnCancel" value="Go Back List" />
    
    @Html.Hidden("orderId", ViewBag.OrderId as string)
    <script type="text/javascript" language="javascript">
        $(document).ready(function () {
            $('#btnCancel').click(function () {
                window.location = '@Url.Content("~/Order")';
            });
            $('#CancelOrder').click(function () {
                var ret = confirm('Are you sure you wish to cancel this order?');
                return ret;
            });
        });
    </script>
}